﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StarryEdge.WPF.Lang
{
    public class LangManager
    {
        #region private
        private string _path = System.IO.Path.Combine(Environment.CurrentDirectory, "lang");
        private static object _obj = new object();
        private static LangManager _instance;
        #endregion
        #region Public
        public static LangManager Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (_obj)
                    {
                        if (_instance == null)
                        {
                            _instance = new LangManager();
                        }
                    }
                }
                return _instance;
            }
        }
        public LangProvider Lang { get; }
        public ToolTipProvider ToolTip { get; }
        #endregion
        private LangManager()
        {
            Lang = new LangProvider(_path);
            ToolTip = new ToolTipProvider(_path);
        }

        public static void SetLang(string lang)
        {
            Instance.Lang.SetLang(lang);
            Instance.ToolTip.SetLang(lang);
        }

        public static void Save()
        { 
            Instance.Lang.SaveKey();
            Instance.ToolTip.SaveKey();
        }

        
    }
}
